<template>
  <div>
    <!-- 位置信息显示 -->
    <div class="positionInfo">
      <el-row :gutter="6" style="font-size: 14px">
        <el-col :span="1">
          <div class="imgInfo">
            <img
              v-if="closeFlag"
              @click="closeInfo"
              style="vertical-align: middle; cursor: pointer; margin-left: 8px"
              src="@/assets/images/home/closeleft.png"
            />
            <img
              v-else
              @click="openInfo"
              style="vertical-align: middle; cursor: pointer; margin-left: 8px"
              src="@/assets/images/home/openright.png"
            />
          </div>
        </el-col>
        <div v-if="textInfo">
          <el-col :span="3"
            >X：{{
              moveMotor == "1"
                ? robotPositionInfo.trackMoveMotor
                : robotPositionInfo.carX
            }}
            mm</el-col
          >
          <el-col v-if="moveMotor != '1'" :span="3"
            >Y：{{ robotPositionInfo.carY || 0 }} mm</el-col
          >
          <el-col :span="3"
            >A：{{
              (Number(robotPositionInfo.carAngle) / 100).toFixed(1) || 0
            }}
            °/s</el-col
          >
          <el-col v-if="isShowSJB" :span="3"
            >L：{{ robotPositionInfo.liftMotor || 0 }} mm</el-col
          >
          <el-col :span="3"
            >P：{{
              (Number(robotPositionInfo.ptzPitchVisble) / 100).toFixed(1) || 0
            }}°</el-col
          >
          <el-col :span="3"
            >T：{{
              (Number(robotPositionInfo.ptzYaw) / 100).toFixed(1) || 0
            }}°</el-col
          >
          <el-col :span="3">Z：{{ cameraInfo.zoom || 0 }}</el-col>
          <el-col :span="2">F：{{ cameraInfo.focus || 0 }}</el-col>
        </div>
      </el-row>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    moveMotor: {
      type: String,
      default: "1",
    },
    robotPositionInfo: {
      type: Object,
      default: () => {},
    },
    isShowSJB: {
      type: Boolean,
      default: false,
    },
    cameraInfo: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      closeFlag: true,
      textInfo: true,
    };
  },
  methods: {
    closeInfo() {
      this.closeFlag = !this.closeFlag;
      var ele = document.querySelector(".positionInfo");
      ele.classList.remove("openInfo");
      ele.classList.add("closeInfo");
      //动画结束后隐藏文字信息
      setTimeout(() => {
        this.textInfo = false;
      }, 500);
    },
    openInfo() {
      this.closeFlag = !this.closeFlag;
      var ele = document.querySelector(".positionInfo");
      ele.classList.remove("closeInfo");
      ele.classList.add("openInfo");
      this.textInfo = true;
    },
  },
};
</script>
<style lang="scss" scoped>
.positionInfo {
  width: 800px;
  height: 36px;
  line-height: 36px;
  position: absolute;
  bottom: 18px;
  right: 130px;
  z-index: 99999;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}
.imgInfo {
  width: 36px;
  height: 36px;
  line-height: 36px;
  // position: absolute;
  // bottom: 18px;
  // left: 84px;
  // z-index: 99999;
  // background: rgba(255, 255, 255, 0.1);
  // border-radius: 2px;
}
// 位置信息展开收缩动画
.closeInfo {
  width: 36px;
  animation: closeInfo 0.5s ease-in;
  -webkit-animation: closeInfo 0.5s ease-in;
}
@keyframes closeInfo {
  0% {
    width: 800px;
  }
  100% {
    width: 36px;
  }
}
.openInfo {
  width: 800px;
  animation: openInfo 0.5s ease-in;
  -webkit-animation: openInfo 0.5s ease-in;
}
@keyframes openInfo {
  0% {
    width: 36px;
  }
  100% {
    width: 800px;
  }
}
</style>
